package java_thinking.unit_15._15_7;

/**
 * @Description :   验证边界问题案例中的非泛型案例，见该类的反编译结果
 * @author: cww
 * @DateTime: 2019/4/4 8:30
 */

public class T_Boders {
    private Object obj;
    public void set(Object obj) {
        this.obj = obj;
    }
    public Object get(){
        return this.obj;
    }

    public static void main(String[] args) {
        T_Boders tBoders = new T_Boders();
        tBoders.set("Item");
        //这里不进行类型装换会警告，因为返回的是Object，窄化转型
        String s = (String)tBoders.get();
    }
}

/**
public class T_Boders {
    public T_Boders();
    Code:
       0: aload_0
       1: invokespecial #1                  // Method java/lang/Object."<init>":()V
       4: return

    public void set(java.lang.Object);      //set()和get()的时候直接产生值,而转型是在调用get()时候受检查的
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #2                  // Field obj:Ljava/lang/Object;
       5: return

    public java.lang.Object get();
    Code:
       0: aload_0
       1: getfield      #2                  // Field obj:Ljava/lang/Object;
       4: areturn

    public static void maindemo(java.lang.String[]);
    Code:
       0: new           #3                  // class T_Boders
       3: dup
       4: invokespecial #4                  // Method "<init>":()V
       7: astore_1
       8: aload_1
       9: ldc           #5                  // String Item
       11: invokevirtual #6                  // Method set:(Ljava/lang/Object;)V
       14: aload_1
       15: invokevirtual #7                  // Method get:()Ljava/lang/Object;
       18: checkcast     #8                  // class java/lang/String      这里会有一个类型检查
       21: astore_2
       22: return
}
*/